package com.power.sifa.approve.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import com.power.sifa.approve.model.Apl_limdelay_hear;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 审理时限延期记录 持久层(hibernate)
 */

public interface Apl_limdelay_hearDao extends JpaRepository<Apl_limdelay_hear, Serializable>, JpaSpecificationExecutor<Apl_limdelay_hear>, Repository<Apl_limdelay_hear, Serializable>, Apl_limdelay_hearDaoCustom<Apl_limdelay_hear, Serializable> {

   @Modifying
   @Transactional
   @Query("delete from Apl_limdelay_hear s where  s.id in (:ids) ")
   void removeByIds(@Param("ids") List<Integer> ids);


   /**
    * 根据子流程applyid删除延期记录
    * @param applyid
    */
   @Modifying
   @Transactional
   @Query(value = " delete from Apl_limdelay_hear s where s.applyid = :applyid")
   void removeBySonApplyid(@Param("applyid") String applyid);

   /**
    * 更新生效日期
    * @param applyid
    * @param effdate
    */
   @Modifying
   @Transactional
   @Query(value = " update  Apl_limdelay_hear s set s.effdate = :effdate where s.applyid = :applyid")
   void updateEffdateBySonApplyid(@Param("applyid") String applyid, @Param("effdate") Date effdate);

   /**
    * 根据子流程applyid查询
    * @param sonapplyid
    * @return
    */
   @Query(value = " from Apl_limdelay_hear s where s.sonapplyid = :sonapplyid")
   Apl_limdelay_hear getBySonApplyid(@Param("sonapplyid") String sonapplyid);

}
